package com.dailyblue.javaee.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import jakarta.servlet.annotation.WebServlet;

import java.io.IOException;

//我对所有的请求都拦截过滤
@WebFilter("/*")
public class FirstFilter implements Filter {

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("触发了FirstFilter操作");
        // 放行
        filterChain.doFilter(servletRequest, servletResponse);
        System.out.println("FirstFilter，我又来了！");
    }
//初始化方法
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("FirstFilter被初始化了");
    }

//销毁方法
    @Override
    public void destroy() {
        System.out.println("FirstFilter被销毁了");
    }

}
